<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');

get_config_keytable("workclass_admin");

empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = $_CONFIG->config_data('pagenum');
	$offset = ($page - 1) * $pagesize;
	if (user_union_id!='') {
			$wheresqls = "  unionid='".user_union_id."'";
		}else{
			$wheresqls = "  unionid='".union_id."'";
		}
	$url = 'admin.php?ac=work_form&fileurl=work&template_id='.$_GET["template_id"].'&type_id='.$_GET["type_id"].'';
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."workclass_form WHERE template_id='".$_GET["template_id"]."' and type_id='".$_GET["type_id"]."' AND ".$wheresqls."");
    $sql = "SELECT * FROM ".DB_TABLEPRE."workclass_form WHERE template_id='".$_GET["template_id"]."' and type_id='".$_GET["type_id"]."' AND ".$wheresqls." ORDER BY id asc LIMIT $offset, $pagesize";
	$result = $db->fetch_all($sql);
	include_once('template/work_form.php');

} elseif ($do == '删 除') {
	get_union_add();
//if (check_purview('file_type_delete')!='1')
//{
// prompt('对不起，你没有权限执行本操作！');
//}
	
	$idarr = getGP('id','P','array');
	foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."workclass_form WHERE id = '$id' and unionid='".union_id."' ");
	//$db->query("DELETE FROM ".DB_TABLEPRE."project_price WHERE project= '$id'");
	$content=$id;
	$title='删除工作流表单';
	get_oa_log_dbadd($id,$content,$title,35,$_USER->id);	
	}
    goto_page('admin.php?ac=work_form&fileurl=work&template_id='.$_GET["template_id"].'&type_id='.$_GET["type_id"].'');

}
?>